package com.ikun.admin.modules.gen.controller;


import com.ikun.admin.common.annotation.OperationAnno;
import com.ikun.admin.modules.gen.entity.CodeConfig;
import com.ikun.admin.modules.gen.entity.FieldType;
import com.ikun.admin.modules.gen.iservice.IFieldTypeService;
import com.ikun.admin.modules.gen.vo.FieldListParamVo;
import com.ikun.admin.modules.gen.vo.FieldTypeCommonVo;
import com.ikun.common.result.Result;
import com.ikun.common.search.PageData;
import com.ikun.common.search.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 字段类型表  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2024-04-03
 */
@RestController
@RequestMapping("/develop/fieldType")
@Api(tags = "类型字典相关接口")
public class FieldTypeController {

    @Autowired
    private IFieldTypeService iFieldTypeService;

    @PostMapping("/fieldType/addOrUpdate/API_001")
    @ApiOperation("新增或者修类型字典接口")
    @OperationAnno(type=0,tableEntity = FieldType.class)
    public Result<String> fieldTypeAddOrUpdate(@RequestBody  FieldTypeCommonVo fieldTypeCommonVo) {
        return iFieldTypeService.fieldTypeAddOrUpdate(fieldTypeCommonVo);
    }

    @PostMapping("/fieldType/list/API_002")
    @ApiOperation("分页查询类型接口")
    public Result<PageResult<FieldTypeCommonVo>> fieldTypeList(@RequestBody PageData<FieldListParamVo> pageData) {
        return iFieldTypeService.fieldTypeList(pageData);
    }

    @GetMapping("/fieldType/dict/API_003")
    @ApiOperation("类型字典 字典接口")
    public Result<List<FieldTypeCommonVo>> fieldTypeDict() {
        return iFieldTypeService.fieldTypeDict();
    }

    @DeleteMapping("/fieldType/delete/API_004/{id}")
    @ApiOperation("单个删除字典接口")
    @OperationAnno(type=1,tableEntity = FieldType.class)
    public Result<String> fieldTypeDelete(@PathVariable Long id) {
        return iFieldTypeService.fieldTypeDelete(id);
    }

    @GetMapping("/fieldType/select/API_005/{id}")
    @ApiOperation("查询详情接口")
    public Result<FieldTypeCommonVo> fieldTypeDetail(@PathVariable Long id){
        return iFieldTypeService.fieldTypeDetail(id);

    }}

